package org.adorsys.aderp.aderplogin.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.entity.RooJpaEntity;
import org.springframework.roo.addon.tostring.RooToString;

@RooJavaBean
@RooToString
@RooJpaEntity
public class AderpUser implements Serializable {

	private static final long serialVersionUID = 1L;

	@NotNull
    @Column(name = "userNumberBk", unique = true)
    private String userNumber;

    @NotNull
    @Column(name = "userNameImtble", unique = true)
    private String userName;

    @NotNull
    @Column(name = "passwordImtble")
    private String password;

    @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private Set<UserRole> roleNames = new HashSet<UserRole>();

    @ManyToOne
    private AderpPersonRef aderpPersonRef;

    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(pattern = "dd-MM-yyyy HH:mm")
    private Date accountExpiration;

    @NotNull
    private boolean disableLogin;

    @NotNull
    private boolean accountLocked;

    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(pattern = "dd-MM-yyyy HH:mm")
    private Date credentialExpiration;

	public AderpUser() {
		super();
		// TODO Auto-generated constructor stub
	}

	public AderpUser(AderpUser orig) {
		super();
		this.userNumber = orig.userNumber;
		this.userName = orig.userName;
		this.password = orig.password;
		this.roleNames = new HashSet<UserRole>(orig.roleNames);
		this.aderpPersonRef = orig.aderpPersonRef;
		this.accountExpiration = orig.accountExpiration;
		this.disableLogin = orig.disableLogin;
		this.accountLocked = orig.accountLocked;
		this.credentialExpiration = orig.credentialExpiration;
	}
    
    
    

    
}
